//
//  OrderDetailProductTableViewCell.m
//  AnXin100
//
//  Created by Sakura on 2018/11/2.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "OrderDetailProductTableViewCell.h"

@interface OrderDetailProductTableViewCell ()

@property (nonatomic, strong) UIImageView *productImage;

@property (nonatomic, strong) UILabel *productNameLabel;

@property (nonatomic, strong) UILabel *priceLabel;

@property (nonatomic, strong) UIView *backView;
@end

@implementation OrderDetailProductTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self creatCell];
    }
    return self;
}

- (void)creatCell {
    
    _backView = [UIView new];
    _backView.backgroundColor = [UIColor colorWithHex:0xf6f6f6];
    [self.contentView addSubview:_backView];
    
    _productImage = [[UIImageView alloc] init];
    _productImage.image = [UIImage imageNamed:@"grape"];
    [self.backView addSubview:_productImage];
    
    _productNameLabel = [UILabel new];
    _productNameLabel.font = [UIFont systemFontOfSize:16];
    _productNameLabel.textColor = [UIColor colorWithHex:0x333333];
    _productNameLabel.text = @"新鲜夏季酸草莓水果1000g 烘焙蛋糕装饰冰饮专用";
    [self.backView addSubview:_productNameLabel];
    
    _priceLabel = [UILabel new];
    _priceLabel.font = [UIFont systemFontOfSize:14];
    _priceLabel.textColor = [UIColor colorWithHex:0xFF9E05];
    _priceLabel.text = @"￥98.00";
    [self.backView addSubview:_priceLabel];
}

- (void)layoutSubviews {
    
    _backView.sd_layout
    .leftEqualToView(self.contentView)
    .rightEqualToView(self.contentView)
    .topSpaceToView(self.contentView, 2)
    .bottomSpaceToView(self.contentView, 2);
    
    _productImage.sd_layout
    .leftSpaceToView(self.backView, 10)
    .topSpaceToView(self.backView, 10)
    .bottomSpaceToView(self.backView, 10)
    .widthIs(114);
    [self.contentView layoutIfNeeded];
    
    _productNameLabel.sd_layout
    .leftSpaceToView(_productImage, 10)
    .rightSpaceToView(self.backView, 10)
    .topEqualToView(_productImage)
    .heightIs(40);
    [self.contentView layoutIfNeeded];

    _priceLabel.sd_layout
    .leftEqualToView(_productNameLabel)
    .bottomEqualToView(_productImage)
    .widthIs(100)
    .heightIs(15);
}

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}

@end
